package cn.sdormitory.smartdor.service.impl;

import cn.sdormitory.smartdor.dao.SdHygieneDao;
import cn.sdormitory.smartdor.entity.SdHygiene;
import cn.sdormitory.smartdor.service.SdHygieneService;
import cn.sdormitory.smartdor.service.SdManualHygieneService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Slf4j
@Service("sdManualHygieneService")
public class SdManualHygieneServiceImpl extends ServiceImpl<SdHygieneDao, SdHygiene>  implements SdManualHygieneService {
    @Resource
    private  SdHygieneDao sdHygieneDao;
    /**
     * 新建卫生信息
     *
     * @param sdHygiene
     * @return
     */
    public int create(SdHygiene sdHygiene){
        return this.baseMapper.insert(sdHygiene);
    }
    /**
     * 根据宿舍ID和 考核时间查询卫生考核信息
     * @param dormitoryId
     * @param checkDate
     * @return
     */
    public SdHygiene getHygieneByDormitoryIdAdndCheckDate(Long dormitoryId,String checkDate){
        return sdHygieneDao.getHygieneByDormitoryIdAdndCheckDate(dormitoryId,checkDate);
    }

    /**
     * 根据ID 获取卫生考核信息
     * @param id
     * @return
     */
    public SdHygiene getSdHygieneById(Long id) {
        return this.sdHygieneDao.getHygieneById(id);
    }
    /**
     * 修卫生考核信息
     *
     * @param id
     * @param sdHygiene
     * @return
     */
    public int update(Long id, SdHygiene sdHygiene){
        sdHygiene.setId(id);
        return this.baseMapper.updateById(sdHygiene);
    }
}
